package com.app.reptile.base;

import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class SchedulerSingleton {

    private static Scheduler INSTANCE = null;

    public static Scheduler getInstance() throws UnknownHostException, SchedulerException {
        if (INSTANCE==null){
            String hostAddress = InetAddress.getLocalHost().getHostAddress();
            AppConfig.CONFIG.put("org.quartz.scheduler.rmi.registryHost", hostAddress);
            StdSchedulerFactory factory = new StdSchedulerFactory(AppConfig.CONFIG);
            INSTANCE = factory.getScheduler();
        }
        return INSTANCE;
    }

}
